package 开始的剑指offer8月.动态规划;
//  https://leetcode-cn.com/problems/ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof/
public class 剑指Offer46把数字翻译成字符串0822 {
    class Solution {
        public int translateNum(int num) {
            String src = String.valueOf(num);
            int p = 0, q = 0, r = 1;
            for (int i = 0; i < src.length(); ++i) {
                p = q;
                q = r;
                r = 0;
                r += q;
                if (i == 0) {
                    continue;
                }
                String pre = src.substring(i - 1, i + 1);
                if (pre.compareTo("25") <= 0 && pre.compareTo("10") >= 0) {
                    r += p;
                }
            }
            return r;
        }
    }

}
